@echo off
echo Installing dependencies...
echo This may take a few minutes...

REM Upgrade pip first
python -m pip install --upgrade pip

REM Try to install dlib from conda-forge if conda is available
echo Checking if conda is available...
conda --version >nul 2>&1
if %errorlevel% == 0 (
    echo Conda found, installing dlib via conda...
    conda install -c conda-forge dlib -y
) else (
    echo Conda not found, trying pip installation...
    echo Checking if Visual Studio Build Tools and CMake are available...
    
    REM Check if cmake is available
    cmake --version >nul 2>&1
    if %errorlevel% == 0 (
        echo CMake found, proceeding with pip installation...
    ) else (
        echo CMake not found. Please install CMake from https://cmake.org/download/
        echo Make sure to add CMake to your system PATH during installation.
        pause
        exit /b 1
    )
    
    REM Check if Visual Studio Build Tools are available
    where cl >nul 2>&1
    if %errorlevel% == 0 (
        echo Visual Studio Build Tools found, proceeding with pip installation...
    ) else (
        echo Visual Studio Build Tools not found.
        echo Please install Visual Studio Build Tools from https://visualstudio.microsoft.com/downloads/
        echo Make sure to include the C++ build tools workload.
        pause
        exit /b 1
    )
    
    REM Try to install pre-compiled wheels first
    echo Installing pre-compiled packages...
    pip install --only-binary=all numpy==1.21.6
    pip install --only-binary=all opencv-python==4.5.5.64
    pip install --only-binary=all Pillow==9.5.0
    
    REM Install dlib
    echo Installing dlib...
    pip install dlib
    
    REM Install other dependencies
    echo Installing other dependencies...
    pip install face-recognition==1.3.0
    pip install Flask==2.0.1
    pip install PyYAML==6.0
    pip install requests==2.25.1
)

echo Installation completed!
pause